package com.cold.legendary.bprocess.common.utils;

import com.cold.legendary.bprocess.common.constance.BErrorCodeEnum;
import com.cold.legendary.bprocess.common.exception.BProcessException;
import org.springframework.util.Assert;

/**
 * 断言工具类
 */
public class BAssertUtil {

    public static void isNull(Object object, BErrorCodeEnum bErrorCodeEnum) {
        try {
            Assert.isNull(object, bErrorCodeEnum.getMsg());
        } catch (RuntimeException e) {
            throw new BProcessException(e);
        }
    }

    public static void notNull(Object object, BErrorCodeEnum bErrorCodeEnum) {
        try {
            Assert.notNull(object, bErrorCodeEnum.getMsg());
        } catch (RuntimeException e) {
            throw new BProcessException(e);
        }
    }

    public static void notBlank(String string, BErrorCodeEnum bErrorCodeEnum) {
        try {
            Assert.hasText(string, bErrorCodeEnum.getMsg());
        } catch (RuntimeException e) {
            throw new BProcessException(e);
        }
    }

    public static void isTrue(boolean boolValue, BErrorCodeEnum bErrorCodeEnum) {
        try {
            Assert.isTrue(boolValue, bErrorCodeEnum.getMsg());
        } catch (RuntimeException e) {
            throw new BProcessException(e);
        }
    }
}
